# Copyright (c) 2018 Presto Labs Pte. Ltd.
# Author: xguo

import json
import os
import logging

from coin2.support.product_info.futures_bitmex_v1 import convert_coin1_constants


pi_file = 'data/coin2/product_info/Futures.Bitmex.v1.json'
with open(pi_file) as f:
  static_constants = convert_coin1_constants(json.load(f)['product_infos'])

dynamic_constants = {}
if int(os.getenv('USE_DYNAMIC_SYMBOL', 0)):
  try:
    from coin2.support.product_info.futures_bitmex_v1 import gen_coin1_constants
    dynamic_constants = gen_coin1_constants()
  except Exception as e:
    logging.error('Failed to use bitmex dynamic symbols! %s', e)

coin_list = list(set(
    static_constants.get('coin_list', []) +
    dynamic_constants.get('coin_list', [])))

fiat_list = list(set(
    static_constants.get('fiat_list', []) +
    dynamic_constants.get('fiat_list', [])))

currency_list = list(set(coin_list + fiat_list))

# Settlement Date, which occurs every 7 days on Friday at 12:00 UTC time.
# thus, date equals to okex futures.
quarter_contract_date = [
    '20180330',
    '20180629',
    '20180928',
    '20181228',
    '20190329',
    '20190628',
    '20190927',
    '20191227',
    '20200327',
    '20200626',
    '20200925',
    '20201225',
    '20210326',
    '20210625',
    '20210924',
    '20211231',
]

contract_type_list = (
    'quarter',
    'next_quarter',
)
